﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.IO;
using System.IO.IsolatedStorage;
using ArgusControls;
using ArgusLight.Fractals2D;

namespace Fractals
{
	class ImageListBoxItem_ : ImageListBoxItem
	{
		public FractalSaveStruct FractalSaveStruct { get; set; }
	}

	public partial class VideoWindow : ChildWindow
	{
		public VideoWindow()
		{
			InitializeComponent();
		}

		protected override void OnOpened()
		{
			base.OnOpened();

			using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
			{
				string[] fileNames = store.GetFileNames(Path.Combine(IsolatedDirectories.Video, "*"));
				foreach (string fileName in fileNames)
				{
					FractalSaveStruct str;
					using (IsolatedStorageFileStream file = store.OpenFile(fileName, FileMode.Open))
					{
						str = FractalSaveStruct.FromStream(file);
						file.Close();
					}

					ImageListBoxItem_ item = new ImageListBoxItem_();
					item.FractalSaveStruct = str;
					item.Text = fileName;
					this.lbKeyPoints.Items.Add(item);
					// Calculate Preview
				}
			}
		}
	}
}

